<template>
    <div id="cornerComment" v-if="dialogVisible">
      <div class="cornerComment-in" ref="dialogBox">
        <div class="cornerComment-in-title">
          <span>反馈明细</span>
          <span class="el-icon-circle-close close-Btn-line" @click="closePOpup"></span>
        </div>
        <div class="commentBody">
          <el-table
              :data="questionList"
              border
              :height="tableHeight"
              style="width: 100%">
            <el-table-column
                prop="id"
                label="ID"
                align="center"
                width="160">
            </el-table-column>
            <el-table-column
                prop="remark"
                label="学生姓名"
                align="center">
              <template slot-scope="scope">
                {{scope.row.student.name}}
              </template>
            </el-table-column>
            <el-table-column
                prop="remark"
                label="家长"
                align="center">
              <template slot-scope="scope">
                {{scope.row.name}}
              </template>
            </el-table-column>
            <el-table-column
                prop="remark"
                label="选项"
                align="center">
              <template slot-scope="scope">
                <span v-for="items in scope.row.write" :key="items.sign_id">{{items.content}}</span>
              </template>
            </el-table-column>
          </el-table>
          <el-col :span="24" class="toolbar">
            <el-pagination
                background
                layout="total,prev, pager, next"
                :total="page.total"
                :page-size="page.pagesize"
                @current-change="handleSizeChange">
            </el-pagination>
          </el-col>
        </div>
        <div class="cornerComment-in-footer">
          <el-button @click="closePOpup" size="small">返回</el-button>
        </div>
      </div>
    </div>
<!--  <el-dialog title="反馈明细" :visible.sync="dialogVisible" @close="$emit('update:visible',false)">-->
<!--    <div class="dialog-body">-->
<!--      <div class="dialog-title">-->
<!--        <span>学生姓名</span>-->
<!--        <span>家长</span>-->
<!--        <span>选项</span>-->
<!--      </div>-->
<!--      <div class="dialog-list" v-for="(item,index) in questionList" :key="index">-->
<!--        <span>{{item.student.name}}</span>-->
<!--        <span>{{item.name}}</span>-->
<!--        <span>-->
<!--          <span v-for="items in item.write" :key="items.sign_id">{{items.content}}</span>-->
<!--        </span>-->
<!--      </div>-->
<!--      <div class="noneDataMore" v-if="!questionList.length">-->
<!--        暂无数据-->
<!--      </div>-->
<!--      <div class="more-list" v-if="is_next"><span @click="morePage">加载更多</span></div>-->
<!--    </div>-->
<!--    <div slot="footer" class="dialog-footer">-->
<!--      <el-button @click="dialogVisible = false" size="small">取 消</el-button>-->
<!--      <el-button type="primary" @click="submitCheckFn" size="small">确 定</el-button>-->
<!--    </div>-->
<!--  </el-dialog>-->

</template>

<script>
  import api from '@/utils/api.js'
  import {pagination, tableoption} from '@/utils/util.js'

  export default {
    name: 'studentMultiple',
    props: ['visible', 'optionId'],
    data () {
      return {
        dialogVisible: this.visible,
        commitment: '',
        questionList: [],
        page: {
          pageindex: pagination.pageIndex,
          pagesize: pagination.pageSize,
          total: pagination.total
        },
        is_next: false,
        tableHeight: 0
      }
    },
    watch: {
      visible () {
        let n =this
        this.dialogVisible = this.visible
        if (this.visible) {
          this.$nextTick(() => {
            let height = n.$refs.dialogBox.offsetHeight;  //top 50 1 search 50 page 50 10 footer 50 1
            n.tableHeight = height - (51 + 20 + 50 + 51)
          })
          this.InitFn()
        }else{
          this.questionList = []
        }
      }
    },
    created () {
    },
    methods: {
      InitFn () {
        this.$fetch(api.admin_questionnaire_option_user, {question_id: this.optionId, p: this.page.pageindex}).then((response) => {
          console.log('response:', response)
          if (response.code === 0) {
            this.questionList = response.list
            this.page.total = response.total
          }
        })
      },
      // 初始化
      submitCheckFn () {
        this.questionList = []
        this.dialogVisible = false
      },
      morePage () {
        this.page.pageindex++
        this.InitFn()
      },
      handleSizeChange(val) {
        this.page.pageindex = val
        this.InitFn()
      },
      closePOpup() {
        this.$emit('update:visible', false)
      },
      getJson(option) {
        return JSON.parse(JSON.stringify(option))
      },
    },
    mounted () {
    }
  }
</script>
<style>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  width: 60%;
  height: 650px;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 10px;
  flex: 1;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}
</style>
